package com.bwda.dsrs.filecenter;

import org.apache.ibatis.mapping.DatabaseIdProvider;
import org.apache.ibatis.mapping.VendorDatabaseIdProvider;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScans;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.util.Properties;

/**
 * @description:
 * @author: yangjun
 * @create: 2019-04-28 11:15
 */

@MapperScan({"com.bwda.dsrs.filecenter.mapper.dsrs","com.bwda.dsrs.systemservice.mapper"})
@EnableDiscoveryClient
@EnableFeignClients(value = {"com.bwda.dsrs.filecenter.api","com.bwda.dsrs.filecenter.api.fileout"})
@SpringBootApplication
@EnableScheduling
@EnableAsync(proxyTargetClass = true)
@ComponentScans(value = {@ComponentScan(value = "com.bwda.dsrs.util"),@ComponentScan(value = "com.bwda.dsrs.service"),@ComponentScan(value = "com.bwda.filecenter")})

public class BusinessServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(BusinessServiceApplication.class, args);
        System.out.println("(♥◠‿◠)ﾉﾞ business  启动成功   ლ(´ڡ`ლ)ﾞ ");
    }

    /**
     * 自动识别使用的数据库类型
     * 在mapper.xml中databaseId的值就是跟这里对应，
     * 如果没有databaseId选择则说明该sql适用所有数据库
     * */
    @Bean
    public DatabaseIdProvider getDatabaseIdProvider(){
        DatabaseIdProvider databaseIdProvider = new VendorDatabaseIdProvider();
        Properties properties = new Properties();
        properties.setProperty("Oracle","oracle");
        properties.setProperty("MySQL","mysql");
        properties.setProperty("DB2","db2");
        properties.setProperty("Derby","derby");
        properties.setProperty("H2","h2");
        properties.setProperty("HSQL","hsql");
        properties.setProperty("Informix","informix");
        properties.setProperty("MS-SQL","ms-sql");
        properties.setProperty("PostgreSQL","postgresql");
        properties.setProperty("Sybase","sybase");
        properties.setProperty("Hana","hana");
        databaseIdProvider.setProperties(properties);
        return databaseIdProvider;
    }

}
